dojo.provide("miaigo.model.StoneBlock");

dojo.require("miaigo.model.PointSet");

dojo.declare(
    "miaigo.model.StoneBlock",
    [miaigo.model.PointSet],
    {
	/* "black" | "white" */
	color: null,

	constructor: function(color)
	{
	    if (color)
	    {
		this.color = color;
	    }
	},

	getColor: function()
	{
	    return this.color;
	},

	// return a BoardState contains the same points and have same color
	clone: function()
	{
	    var newBlock = new miaigo.model.StoneBlock(this.color);
	    for (i in this.points)
	    {
		newBlock.addPoint(this.points[i].x, this.points[i].y);
	    }
	    return newBlock;
	},

	// merge another block
	merge: function(block)
	{
	    if (this.color != block.color)
	    {
		// cannot merge blocks with different colors
		return null;
	    }

	    // ??? Test if the two blocks adjacent?

	    this.addPoints(block.points);
	    return this;
	}
    });